package com.sky.mapper;

import com.sky.dto.CategoryDTO;
import com.sky.entity.Category;
import com.sky.pojo.StatusUpdate;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Select("select id, type, name, sort, status, create_time," +
            " update_time, create_user, update_user from category where status = 1 and type =#{type} order by sort")
    List<Category> listByType(Integer type);

    @Select("select id, type, name, sort, status, create_time," +
            "update_time, create_user, update_user from category order by sort")
    List<Category> list();

    @Update("update category set status=#{status} where id =#{id}")
    void status(StatusUpdate statusUpdate);

    @Update("update category set name=#{name}, sort=#{sort} where id =#{id}")
    void update(Category category);

    @Insert("insert into category(type, name, sort) values (#{type}, #{name}, #{sort})")
    void addCategory(Category category);

    @Delete("delete from category where id = #{id}")
    void deleteById(Long id);

    @Select("select * from category where id = #{categoryId} ")
    Category getBySetmealId(Long categoryId);
}
